<%@ page language="java"  pageEncoding="UTF-8"%>
<%@ include file="/views/commons/taglibs.jsp" %>
<div class="panel-heading">
	<div class="pull-right">
		<a href="<%=path %>/base/adminUser/toInsert" target="_blank">创建管理员帐号</a>
	</div>
	<h3 class="panel-title">管理员帐号列表</h3>
</div>
<div class="bd clearfix">
	<form id="base_account_choose_form" action="javascript:void(0);">
		<div class="filter-wrap">
			<dl class="clearfix invest-filter">
				<dt>姓名</dt>
				<dd >
					<div class="col-sm-5 mb20">
						<div class="input-group">
							<input type="text" name="userName" size="25" value="${paramMap.userName}" class="form-control" placeholder="请输入姓名关键字">
						</div>
					</div>
				</dd>
			
				<dt>帐号</dt>
				<dd >
					<div class="col-sm-4 mb20">
						<div class="input-group">
							<input type="text" name="userAccount" size="25" value="${paramMap.userAccount}" class="form-control" placeholder="请输入帐号">
							<span class="input-group-btn">
								<button class="btn btn-primary" type="button" onclick="javascript:queryAccountList(1);">搜索</button>
							</span>							
						</div>
					</div>
				</dd>
			</dl>
		</div>
	</form>
</div>
<c:choose>
<c:when test="${!empty dataList && fn:length(dataList) ne 0}">
<table class="table">
	<thead>
		<tr>
			<th width="30%">姓名</th>
			<th width="30%">帐号</th>
			<th width="40%">操作</th>
		</tr>
	</thead>
	<tbody>
		<c:forEach var="adminUser" items="${dataList}" varStatus="index">
		<tr>
			<td class="title">${adminUser.userName}</td>
			<td>${adminUser.userAccount}</td>
			<td>
				<a href="javascript:deleteAccount('${adminUser.adminUserId}')" >删除管理帐号</a>
				<a href="javascript:resetPassword('${adminUser.adminUserId}')" >重置密码</a>
				<a href="<%=path %>/base/adminUser/view/${adminUser.adminUserId}" target="_blank">分配权限</a>
			</td>
		</tr>
		</c:forEach>
	</tbody>
</table>
<!-- 分页 -->
<p:pagination pageNo="${paramMap.pageNo}" pageCount="${paramMap.pageCount}" queryFunction="queryAccountList" style="text-center"></p:pagination>
<!-- 分页 end -->
</c:when>
<c:otherwise>
	<table class="table">
		<thead>
			<tr>
				<th width="30%">姓名</th>
				<th width="30%">帐号</th>
				<th width="40%">操作</th>
			</tr>
		</thead>
		<tbody>
			<tr>
				<td colspan="3" align="center">
					暂无数据
				</td>
			</tr>
		</tbody>
	</table>
</c:otherwise>
</c:choose>
<script type="text/javascript">
	function deleteAccount(adminUserId) {
		$.ajax({
			url : path + "/base/adminUser/delete/" + adminUserId,
			type : "post",
			dataType : "json",
			success : function(data) {
				if (data.result) {
					layer.msg("删除商品成功", {
						icon : 1
					});
					queryAccountList(1);
				} else {
					layer.msg(data.message, {
						icon : 2
					});
					;
				}
			},
			error : function() {
				layer.msg("服务器网络繁忙", {
					icon : 2
				});
			}
		});
	}
	
	function resetPassword(adminUserId) {
		$.ajax({
			url : path + "/base/adminUser/resetPassword?adminUserId=" + adminUserId,
			type : "post",
			dataType : "json",
			success : function(data) {
				if (data.result) {
					layer.msg("重置密码成功", {
						icon : 1
					});
					queryAdminGoodsList(1);
				} else {
					layer.msg(data.message, {
						icon : 2
					});
					;
				}
			},
			error : function() {
				layer.msg("服务器网络繁忙", {
					icon : 2
				});
			}
		});
	}
	
</script>